#!/bin/sh

# Pipes input from an builtin command thru an external one.

. ${KASH_TEST_DIR}/common-include.sh

TMPFILE1="/tmp/pipe-2a.$$.tmp"
TMPFILE2="/tmp/pipe-2b.$$.tmp"
echo piped > $TMPFILE1
$CMD_CAT $TMPFILE1 \
	| $CMD_SED -e 's/piped/abc/' \
	| $CMD_SED -e 's/abc/def/'  \
	| $CMD_SED -e 's/def/ghi/'  \
	| $CMD_SED -e 's/ghi/jkl/'  \
	| $CMD_SED -e 's/jkl/mno/'  \
	| $CMD_SED -e 's/mno/pqr/'  \
	| $CMD_SED -e 's/pqr/stu/'  \
	| $CMD_SED -e 's/stu/vwx/'  \
	| $CMD_SED -e 's/vwx/yz_/'  \
	> $TMPFILE2

VAR=`$CMD_CAT $TMPFILE2`
$CMD_RM -f -- $TMPFILE1 $TMPFILE2
if test "$VAR" != "yz_"; then
    echo "pipe-2: FAILURE - VAR=$VAR"
    exit 1
fi
echo "pipe-2: SUCCESS"
exit 0

